<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Namespace: MQTT</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Namespace: MQTT</h1>

    




<section>

<header>
    
        <h2>MQTT</h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        
            <div class="description">Send and receive messages using web browsers.
<p>
This programming interface lets a JavaScript client application use the MQTT V3.1 or
V3.1.1 protocol to connect to an MQTT-supporting messaging server.

The function supported includes:
<ol>
<li>Connecting to and disconnecting from a server. The server is identified by its host name and port number.
<li>Specifying options that relate to the communications link with the server,
for example the frequency of keep-alive heartbeats, and whether SSL/TLS is required.
<li>Subscribing to and receiving messages from MQTT Topics.
<li>Publishing messages to MQTT Topics.
</ol>
<p>
The API consists of two main objects:
<dl>
<dt><b><a href="Paho.MQTT.Client.html">Paho.MQTT.Client</a></b></dt>
<dd>This contains methods that provide the functionality of the API,
including provision of callbacks that notify the application when a message
arrives from or is delivered to the messaging server,
or when the status of its connection to the messaging server changes.</dd>
<dt><b><a href="Paho.MQTT.Message.html">Paho.MQTT.Message</a></b></dt>
<dd>This encapsulates the payload of the message along with various attributes
associated with its delivery, in particular the destination to which it has
been (or is about to be) sent.</dd>
</dl>
<p>
The programming interface validates parameters passed to it, and will throw
an Error containing an error message intended for developer use, if it detects
an error with any parameter.
<p>
Example:

<code><pre>
client = new Paho.MQTT.Client(location.hostname, Number(location.port), "clientId");
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
client.connect({onSuccess:onConnect});

function onConnect() {
  // Once a connection has been made, make a subscription and send a message.
  console.log("onConnect");
  client.subscribe("/World");
  message = new Paho.MQTT.Message("Hello");
  message.destinationName = "/World";
  client.send(message);
};
function onConnectionLost(responseObject) {
  if (responseObject.errorCode !== 0)
	console.log("onConnectionLost:"+responseObject.errorMessage);
};
function onMessageArrived(message) {
  console.log("onMessageArrived:"+message.payloadString);
  client.disconnect();
};
</pre></code></div>
        

        


<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="paho-mqtt.js.html">paho-mqtt.js</a>, <a href="paho-mqtt.js.html#line23">line 23</a>
    </li></ul></dd>
    

    

    

    
</dl>


        
    
    </div>

    

    

    
        <h3 class="subsection-title">Classes</h3>

        <dl>
            <dt><a href="Paho.MQTT.Client.html">Client</a></dt>
            <dd></dd>
        
            <dt><a href="Paho.MQTT.Message.html">Message</a></dt>
            <dd></dd>
        </dl>
    

    

    

    

    

    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Paho.MQTT.Client.html">Client</a></li><li><a href="Paho.MQTT.Message.html">Message</a></li></ul><h3>Namespaces</h3><ul><li><a href="Paho.MQTT.html">MQTT</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Aug 04 2017 09:22:59 GMT+0100 (BST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>